<?php

require_once(OC_App::getAppPath('company') . "/lib/subaccounts.php");

$LoginStats = PUtil::checkUserLogin(true);
if ($LoginStats !== true) {
   echo $LoginStats;
   exit();
}

OCP\JSON::callCheck();

$uid = JRequest::getString("uid", "");
$block = JRequest::getInt("block", 0) ? 1 : 0;

$model = new PCompanyModelSubAccounts;

if($model->switchSubAccount($uid, $block)) {
   OCP\JSON::success();
} else {
   OCP\JSON::error(array('error' => $model->getError() ? $model->getError() : '系统错误'));
}
